const { defineConfig } = require("@vue/cli-service");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");

const { resolve } = require("path");

module.exports = defineConfig({
  publicPath: "./", // 基本路径
  transpileDependencies: true,
  lintOnSave: false,
  chainWebpack: (config) => {
    config.module.rules.delete("svg"); // 重点，删除默认配置中处理svg
    config.module
      .rule("svg-sprite-loader")
      .test(/\.svg$/)
      .include.add(resolve("src/assets/icons/imgs"))
      .end()
      .use("svg-sprite-loader")
      .loader("svg-sprite-loader")
      .options({
        symbolId: "[name]",
        // symbolId: "icon-[name]",
      });
  },
  css: {
    loaderOptions: {
      scss: {
        additionalData: `@import "~@/assets/styles/_variables.scss";`,
      },
    },
  },
  pluginOptions: {
    "style-resources-loader": {
      preProcessor: "scss",
      patterns: [],
    },
  },
  // devServer: {
  //   hot: true,
  //   open: true,
  //   host: "localhost",
  // },
  configureWebpack: {
    plugins: [new NodePolyfillPlugin()],
  },
});
